﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterAdmin.master" AutoEventWireup="true" CodeBehind="InsertTimeEmp.aspx.cs" Inherits="UdrinkWater_Project.Admin.InsertTimeEmp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
    <script type="text/javascript">
    // <![CDATA[
        function ShowLoginWindow() {
            pcLogin.Show();
        }
        function ShowWindow() {
            popup_Out.Show();
        }
    // ]]> 
    </script>
  <dx:ASPxRoundPanel ID="ASPxRoundPanel1" runat="server" 
        HeaderText="บันทึกเวลาเข้า-ออกงาน พนักงาน" Width="100%">
        <HeaderStyle Font-Size="Medium" HorizontalAlign="Left" />
        <PanelCollection>
<dx:PanelContent runat="server" SupportsDisabledAttribute="True">
    <dx:ASPxPageControl ID="ASPxPageControl1" runat="server" ActiveTabIndex="0" 
        Width="100%">
        <TabPages>
            <dx:TabPage Text="ลงเวลาเข้างาน">
                <ContentCollection>
                    <dx:ContentControl ID="ContentControl1" runat="server" SupportsDisabledAttribute="True">
                         <table style="width: 100%">
        <tr>
            <td style="width: 177px">
                <dx:ASPxRadioButtonList ID="listbox_timecheck" runat="server" 
                    RepeatDirection="Horizontal" SelectedIndex="0" Width="300px">
                    <Items>
                        <dx:ListEditItem Selected="True" Text="ลงเวลาเข้างานปกติ" Value="0" />
                        <dx:ListEditItem Text="ลงเวลาเข้างานล่วงเวลา" Value="1" />
                    </Items>
                </dx:ASPxRadioButtonList>
            </td>
            <td>
                <dx:ASPxButton ID="bt_ConfirmInsert" runat="server" Text="บันทึก" 
                    AutoPostBack="False" UseSubmitBehavior="False">
                     <ClientSideEvents Click="function(s, e) { ShowLoginWindow(); }" />
                  </dx:ASPxButton>
            </td>
        </tr>
    </table>
    <div>
        <table style="width: 100%">
            <tr>
                <td style="width: 103px">
                    <dx:ASPxButton ID="bt_SelectAll" runat="server" Text="เลือกทั้งหมด" 
                        AutoPostBack="False">
                         <ClientSideEvents Click="function() { GV_ListEmp.SelectAllRowsOnPage() }" />
                    </dx:ASPxButton>
                </td>
                <td>
                    <dx:ASPxButton ID="bt_UnselectAll" runat="server" Text="ไม่เลือกทั้งหมด" 
                        AutoPostBack="False" UseSubmitBehavior="True">
                         <ClientSideEvents Click="function() { GV_ListEmp.UnselectAllRowsOnPage() }" />
                    </dx:ASPxButton>
                </td>
            </tr>
        </table>
    </div>
    <dx:ASPxGridView ID="GV_ListEmp" runat="server" AutoGenerateColumns="False" ClientInstanceName="GV_ListEmp"
        DataSourceID="SqlDataSource_DataEmp" Font-Size="Small" KeyFieldName="ID_Card" 
        Width="100%">
        <Columns>
            <dx:GridViewCommandColumn ShowSelectCheckbox="True" VisibleIndex="6" 
                Caption="ลงเวลาเข้างาน">
                <SelectButton Text="ปกติ">
                </SelectButton>
                <HeaderStyle HorizontalAlign="Center" />
            </dx:GridViewCommandColumn>
            <dx:GridViewDataTextColumn Caption="รหัสพนักงาน" FieldName="ID_Card" 
                ReadOnly="True" ShowInCustomizationForm="True" VisibleIndex="0">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn Caption="คำนำหน้า" FieldName="Prefix" 
                ShowInCustomizationForm="True" VisibleIndex="1">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn Caption="ชื่อ" FieldName="Firstname" 
                ShowInCustomizationForm="True" VisibleIndex="2">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn Caption="นามสกุล" FieldName="Lastname" 
                ShowInCustomizationForm="True" VisibleIndex="3">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn Caption="ตำแหน่ง" FieldName="Department_Name" 
                ShowInCustomizationForm="True" VisibleIndex="4">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn Caption="เบอร์โทรศัพท์" FieldName="Tel" 
                ShowInCustomizationForm="True" VisibleIndex="5">
            </dx:GridViewDataTextColumn>
        </Columns>
        <SettingsBehavior AllowDragDrop="False" AllowGroup="False" />
        <SettingsPager Mode="ShowAllRecords">
        </SettingsPager>
    </dx:ASPxGridView>
                    </dx:ContentControl>
                </ContentCollection>
            </dx:TabPage>
            <dx:TabPage Text="ลงเวลาออกงาน">
                <ContentCollection>
                    <dx:ContentControl ID="ContentControl2" runat="server" SupportsDisabledAttribute="True">
                         <table style="width: 100%">
                             <tr>
                                 <td style="width: 177px">
                                     <dx:ASPxRadioButtonList ID="listbox_timecheckOut" runat="server" 
                                         RepeatDirection="Horizontal" SelectedIndex="0" Width="300px">
                                         <Items>
                                             <dx:ListEditItem Selected="True" Text="ลงเวลาออกงานปกติ" Value="0" />
                                             <dx:ListEditItem Text="ลงเวลาออกงานล่วงเวลา" Value="1" />
                                         </Items>
                                     </dx:ASPxRadioButtonList>
                                 </td>
                                 <td>
                                     <dx:ASPxButton ID="bt_ConfirmOut" runat="server" Text="บันทึก" Width="80px" 
                                         AutoPostBack="False" UseSubmitBehavior="False">
                                         <ClientSideEvents Click="function(s, e) { ShowWindow(); }" />
                                     </dx:ASPxButton>
                                 </td>
                             </tr>
                             <tr>
                                 <td style="width: 177px">
                                     <table style="width: 100%">
                                         <tr>
                                             <td>
                                                 <dx:ASPxDateEdit ID="DateEdit_Find" runat="server" 
                                                     DisplayFormatString="dd MMMM yyyy">
                                                 </dx:ASPxDateEdit>
                                             </td>
                                             <td>
                                                 <dx:ASPxButton ID="bt_TimeFind" runat="server" OnClick="bt_TimeFind_Click" 
                                                     Text="ค้นหา" Width="80px">
                                                 </dx:ASPxButton>
                                             </td>
                                         </tr>
                                     </table>
                                 </td>
                                 <td>
                                     &nbsp;</td>
                             </tr>
    </table>
    <div>
        <table style="width: 100%">
            <tr>
                <td style="width: 103px">
                    <dx:ASPxButton ID="bt_SelectAllOut" runat="server" Text="เลือกทั้งหมด" 
                        AutoPostBack="False">
                         <ClientSideEvents Click="function() { GV_ListEmpOut.SelectAllRowsOnPage() }" />
                    </dx:ASPxButton>
                </td>
                <td>
                    <dx:ASPxButton ID="bt_UnselectOut" runat="server" Text="ไม่เลือกทั้งหมด" 
                        AutoPostBack="False">
                         <ClientSideEvents Click="function() { GV_ListEmpOut.UnselectAllRowsOnPage() }" />
                    </dx:ASPxButton>
                </td>
            </tr>
        </table>
    </div>
    <dx:ASPxGridView ID="GV_ListEmpOut" runat="server" AutoGenerateColumns="False" ClientInstanceName="GV_ListEmpOut"
        DataSourceID="SqlDataSource_ShowEmpCheckIn" Font-Size="Small" 
        Width="100%" KeyFieldName="ID_Card">
        <Columns>
            <dx:GridViewCommandColumn Caption="ลงชื่อออกงาน" ShowInCustomizationForm="True" 
                ShowSelectCheckbox="True" VisibleIndex="7">
                <HeaderStyle HorizontalAlign="Center" />
                <CellStyle HorizontalAlign="Center">
                </CellStyle>
            </dx:GridViewCommandColumn>
            <dx:GridViewDataTextColumn FieldName="ID_Card" 
                ShowInCustomizationForm="True" VisibleIndex="0" Caption="รหัสพนักงาน" 
                ReadOnly="True">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn FieldName="Prefix" 
                ShowInCustomizationForm="True" VisibleIndex="1" Caption="คำนำหน้าชื่อ">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn FieldName="Firstname" 
                ShowInCustomizationForm="True" VisibleIndex="2" Caption="ชื่อ">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn FieldName="Lastname" 
                ShowInCustomizationForm="True" VisibleIndex="3" Caption="นามสกุล">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn FieldName="Department_Name" 
                ShowInCustomizationForm="True" VisibleIndex="4" Caption="ตำแหน่ง">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn FieldName="Tel" 
                ShowInCustomizationForm="True" VisibleIndex="5" Caption="เบอร์โทรศัพท์">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataDateColumn FieldName="CheckIn_Date" 
                ShowInCustomizationForm="True" VisibleIndex="6" Caption="วันที่ทำงาน">
                <PropertiesDateEdit DisplayFormatString="dd MMMM yyyy">
                </PropertiesDateEdit>
            </dx:GridViewDataDateColumn>
        </Columns>
        <SettingsBehavior AllowDragDrop="False" AllowGroup="False" />
        <SettingsPager Mode="ShowAllRecords">
        </SettingsPager>
    </dx:ASPxGridView>
                         <asp:SqlDataSource ID="SqlDataSource_ShowEmpCheckIn" runat="server" 
                             ConnectionString="<%$ ConnectionStrings:DB_Udrink %>" 
                             SelectCommand="SELECT TB_Employee.ID_Card, TB_Employee.Prefix, TB_Employee.Firstname, TB_Employee.Lastname, 
TB_Department.Department_Name, TB_Employee.Tel, TB_EmpCheckIn.CheckIn_Date FROM TB_Employee 
INNER JOIN TB_EmpCheckIn ON TB_Employee.ID_Card = TB_EmpCheckIn.Employee_ID 
INNER JOIN TB_Department ON TB_Employee.Department_ID = TB_Department.Department_ID 
WHERE TB_EmpCheckIn.Status_Check is null AND TB_EmpCheckIn.CheckIn_Date=@Date">
                             <SelectParameters>
                                 <asp:SessionParameter Name="Date" SessionField="DateNow" DefaultValue="" />
                             </SelectParameters>
                         </asp:SqlDataSource>
                    </dx:ContentControl>
                </ContentCollection>
            </dx:TabPage>
        </TabPages>
    </dx:ASPxPageControl>

            <asp:SqlDataSource ID="SqlDataSource_DataEmp" runat="server" 
        ConnectionString="<%$ ConnectionStrings:DB_Udrink %>" 
        
        SelectCommand="SELECT TB_Employee.ID_Card, TB_Employee.Prefix, TB_Employee.Firstname, TB_Employee.Lastname, TB_Department.Department_Name, TB_Employee.Tel FROM TB_Employee INNER JOIN TB_Department ON TB_Employee.Department_ID = TB_Department.Department_ID ORDER BY TB_Employee.Firstname ASC">
    </asp:SqlDataSource>
            </dx:PanelContent>
</PanelCollection>
    </dx:ASPxRoundPanel>
     <dx:ASPxPopupControl ID="pcLogin" runat="server" CloseAction="CloseButton" Modal="True"
        PopupHorizontalAlign="WindowCenter" PopupVerticalAlign="WindowCenter" ClientInstanceName="pcLogin"
        HeaderText="เวลาเข้างาน" AllowDragging="True" 
        PopupAnimationType="None" EnableViewState="False" Font-Size="16px" 
        Width="333px">
        <ContentCollection>
            <dx:PopupControlContentControl ID="PopupControlContentControl1" runat="server">
                <dx:ASPxPanel ID="Panel1" runat="server" DefaultButton="btOK">
                    <PanelCollection>
                        <dx:PanelContent ID="PanelContent1" runat="server">
                            <table>
                                <tr>
                                    <td rowspan="2">
                                        <div class="pcmSideSpacer">
                                        </div>
                                    </td>
                                    <td class="pcmCellCaption" style="width: 121px">
                                        <dx:ASPxLabel ID="lblPass1" runat="server" Text="วันที่และเวลา" 
                                            AssociatedControlID="tbPassword" Font-Size="16px">
                                        </dx:ASPxLabel>
                                    </td>
                                    <td class="pcmCellText">
                                        <dx:ASPxDateEdit ID="dateEdit" runat="server" EditFormat="DateTime" 
                                            DisplayFormatString="dd MMMM yyyy hh:mm">
                                            <TimeSectionProperties Visible="True">
                        <TimeEditProperties EditFormatString="HH:mm" />
                    </TimeSectionProperties>
                                        </dx:ASPxDateEdit>
                                    </td>
                                    <td rowspan="2">
                                        <div class="pcmSideSpacer">
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="pcmCellCaption" style="width: 121px">
                                        &nbsp;</td>
                                    <td class="pcmCellText">
                                        <table style="width: 100%">
                                            <tr>
                                                <td>
                                                    <dx:ASPxButton ID="btOK" runat="server" AutoPostBack="False" 
                                                        style="float: left; margin-right: 8px" Text="ตกลง" Width="80px" 
                                                        OnClick="btOK_Click">
                                                        <ClientSideEvents Click="function(s, e) { if(ASPxClientEdit.ValidateGroup('entryGroup')) pcLogin.Hide(); }" />
                                                    </dx:ASPxButton>
                                                </td>
                                                <td>
                                                    <dx:ASPxButton ID="btCancel" runat="server" AutoPostBack="False" 
                                                        style="float: left; margin-right: 8px" Text="ยกเลิก" Width="80px">
                                                        <ClientSideEvents Click="function(s, e) { pcLogin.Hide(); }" />
                                                    </dx:ASPxButton>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                            </table>
                        </dx:PanelContent>
                    </PanelCollection>
                </dx:ASPxPanel>
                <div>
                    &nbsp;</div>
            </dx:PopupControlContentControl>
        </ContentCollection>
        <ContentStyle>
            <Paddings PaddingBottom="5px" />
        </ContentStyle>
    </dx:ASPxPopupControl>
    
    <dx:ASPxPopupControl ID="popup_Out" runat="server" 
        CloseAction="CloseButton" Modal="True"
        PopupHorizontalAlign="WindowCenter" PopupVerticalAlign="WindowCenter" ClientInstanceName="popup_Out"
        HeaderText="เวลาออกงาน" AllowDragging="True" 
        PopupAnimationType="None" EnableViewState="False" Font-Size="16px" 
        Width="333px">
       
        <ContentCollection>
            <dx:PopupControlContentControl ID="PopupControlContentControl2" runat="server">
                <dx:ASPxPanel ID="ASPxPanel1" runat="server" DefaultButton="btOK">
                    <PanelCollection>
                        <dx:PanelContent ID="PanelContent2" runat="server">
                            <table>
                                <tr>
                                    <td rowspan="2">
                                        <div class="pcmSideSpacer">
                                        </div>
                                    </td>
                                    <td class="pcmCellCaption" style="width: 121px">
                                        <dx:ASPxLabel ID="ASPxLabel1" runat="server" Text="วันที่และเวลา" 
                                            AssociatedControlID="tbPassword" Font-Size="16px">
                                        </dx:ASPxLabel>
                                    </td>
                                    <td class="pcmCellText">
                                        <dx:ASPxTimeEdit ID="TimeEdit_CheckOut" runat="server" 
                                            DisplayFormatString="HH:mm:ss" EditFormat="Custom" EditFormatString="HH:mm:ss">
                                        </dx:ASPxTimeEdit>
                                    </td>
                                    <td rowspan="2">
                                        <div class="pcmSideSpacer">
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="pcmCellCaption" style="width: 121px">
                                        &nbsp;</td>
                                    <td class="pcmCellText">
                                        <table style="width: 100%">
                                            <tr>
                                                <td>
                                                    <dx:ASPxButton ID="bt_Confirm_Out" runat="server" AutoPostBack="False" 
                                                        style="float: left; margin-right: 8px" Text="ตกลง" Width="80px" 
                                                        OnClick="bt_Confirm_Out_Click">
                                                        <ClientSideEvents Click="function(s, e) { if(ASPxClientEdit.ValidateGroup('entryGroup')) popup_Out.Hide(); }" />
                                                    </dx:ASPxButton>
                                                </td>
                                                <td>
                                                    <dx:ASPxButton ID="bt_cancleOut" runat="server" AutoPostBack="False" 
                                                        style="float: left; margin-right: 8px" Text="ยกเลิก" Width="80px">
                                                        <ClientSideEvents Click="function(s, e) { popup_Out.Hide(); }" />
                                                    </dx:ASPxButton>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                            </table>
                        </dx:PanelContent>
                    </PanelCollection>
                </dx:ASPxPanel>
                <div>
                    &nbsp;</div>
            </dx:PopupControlContentControl>
        </ContentCollection>
        <ContentStyle>
            <Paddings PaddingBottom="5px" />
        </ContentStyle>
    </dx:ASPxPopupControl>
</asp:Content>
